package com.panda.mall.user.account.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panda.mall.common.mallUser.dto.QueryUserDto;
import com.panda.mall.common.mallUser.entity.SystemUser;
import com.panda.mall.common.result.Result;
import com.panda.mall.user.account.service.SystemAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * author: tcy
 * createDate: 2023/6/13
 * description:商城用户
 */
@Api(tags = "商城账户")
@RestController
@RequestMapping("/user")
public class SystemAccountController {

    @Autowired
    SystemAccountService systemAccountService;

    @ApiOperation(value = "增改商城账户", notes = "增改商城账户")
    @PostMapping("/saveOrUpdateUser")
    public Result<Boolean> saveOrUpdateUser(@RequestBody SystemUser systemUser) {
        return Result.success(systemAccountService.saveOrUpdateUser(systemUser));
    }

    @ApiOperation(value = "匹配查询商城账户", notes = "匹配查询商城账户")
    @PostMapping("/queryAllUser")
    public Result<Page<SystemUser>> queryAllUser(@RequestBody QueryUserDto dto) {
        return Result.success(systemAccountService.queryAllUser(dto));
    }

    @ApiOperation(value = "查询商城账户详情", notes = "查询商城账户详情")
    @GetMapping("/queryUserById/{id}")
    public Result<SystemUser> queryUserById(@PathVariable("id") Long id) {
        return Result.success(systemAccountService.queryUserById(id));
    }

    @ApiOperation(value = "删除商城账户", notes = "删除商城账户")
    @PostMapping("/deleteUser")
    public Result<Boolean> deleteUser(@RequestBody List<Long> ids) {
        return Result.success(systemAccountService.deleteUser(ids));
    }

}
